package heima3_2.cn.osc.base;

import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import net.oschina.app.R;

import heima3_2.cn.osc.constant.ResultState;
import heima3_2.cn.osc.ui.view.AutoLoadListView;

/**
 * Created by yaozhanlie on 2017/1/18.
 */

public abstract class OurTabBaseFragment extends BaseFragment implements AutoLoadListView.Pagingable{

    protected int index = 0;
    public AutoLoadListView mSoftList;
    public MyBaseAdapter mSoftAdapter;
    @Override
    protected ResultState onLoadSubData() {
        return ResultState.LOAD_SUCCESS;
    }

    @Override
    protected View onCreateSubSuccessView(LayoutInflater inflater, ViewGroup container) {
        View view = inflater.inflate(R.layout.fragment_swiperefreshlayout, container,false);
        mSoftList = (AutoLoadListView) view.findViewById(R.id.listViews_dyn);
        mSoftAdapter = getAdapter(getActivity(),null);
        mSoftList.setAdapter(mSoftAdapter);
        initPresenter();
        return view;
    }

    protected abstract MyBaseAdapter getAdapter(FragmentActivity activity, Object o);

    /**需要子类自己去获取数据
     * 模板：mPresenter = new CollectSoftPresenter(this);
     * mPresenter.getData(0);
     * */
    public abstract void initPresenter();

//        mPresenter = new CollectSoftPresenter(this);
//        mPresenter.getData(0);


    @Override
    public void onLoadMoreItems() {
        getMoreData();
    }
    /**子类去写加载更多数据的方法啊，需要用子类自己的适配器去getData（index++）*/
    public abstract void getMoreData();
}
